package com.wealth.scsj.p_app.view.activity;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.gigamole.navigationtabstrip.NavigationTabStrip;
import com.wealth.scsj.p_app.R;
import com.wealth.scsj.p_app.adapter.FragmentAdapter;
import com.wealth.scsj.p_app.view.fragment.BaseFragment;
import com.wealth.scsj.p_app.view.fragment.ServicePointsListFragment;

import java.util.ArrayList;

/**
 * 服务分详情
 * @author qxp
 */
public class ServicePointsDetailsActivity extends BaseActivity implements View.OnClickListener {

    private TextView mToolbarTitle;
    /**
     * 编辑
     */
    private TextView mToolbarTitleRight;
    private ImageView mToolbarTitleLeft;
    /**
     * 100
     */
    private TextView mServicePointsMuchTv;
    private NavigationTabStrip mMediatorTab;
    private ViewPager mViewpager;

    private String[] titles = {"全部", "昨天", "近七天","近一月"};
    private FragmentAdapter mainFragmentAdapter;
    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_service_points_details);
    }

    @Override
    protected void initView() {

        mToolbarTitle = findViewById(R.id.toolbar_title);
        mToolbarTitleRight =  findViewById(R.id.toolbar_title_right);
        mToolbarTitleLeft =  findViewById(R.id.toolbar_title_left);
        mServicePointsMuchTv = findViewById(R.id.service_points_much_tv);
        mMediatorTab =  findViewById(R.id.mediator_tab);
        mViewpager =  findViewById(R.id.viewpager);
    }

    @Override
    protected void initListener() {
        mToolbarTitleRight.setOnClickListener(this);
        mToolbarTitleLeft.setOnClickListener(this);
        mMediatorTab.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        mToolbarTitle.setText("服务分明细");
        mToolbarTitle.setTextColor(getResources().getColor(R.color.white));
        mToolbarTitleRight.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.service_point_help_icon,0,0,0);
        //TODO 右上角问好 为实现

        mViewpager.setOffscreenPageLimit(4);
        ArrayList<BaseFragment> list = new ArrayList<>();

        list.add(ServicePointsListFragment.getIntent(0));
        list.add(ServicePointsListFragment.getIntent(1));
        list.add(ServicePointsListFragment.getIntent(2));
        list.add(ServicePointsListFragment.getIntent(3));

        mainFragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), list);
        mViewpager.setAdapter(mainFragmentAdapter);
        mMediatorTab.setViewPager(mViewpager, 0);
        mMediatorTab.setTitles(titles);
        mMediatorTab.setStripType(NavigationTabStrip.StripType.LINE);
        mMediatorTab.setStripGravity(NavigationTabStrip.StripGravity.BOTTOM);
        mMediatorTab.setTabIndex(0, true);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.toolbar_title_right:
                break;
            case R.id.toolbar_title_left:
                finish();
                break;
            case R.id.mediator_tab:
                break;
        }
    }
}
